package com.junmo.oauth.module.system.dao;


import com.junmo.oauth.module.system.entity.SysResource;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

@Repository
public interface SysResourceRepository extends JpaRepository<SysResource, Long>, JpaSpecificationExecutor {
    List<SysResource> findAllByOrderByResourceSortAsc();

    SysResource findByResourceCode(String resourceCode);

    List<SysResource> findByResourceType(String resourceType);
    List<SysResource> findByResourceTypeIn(Collection<String> resourceTypes);



////--  父 求 子
//WITH RECURSIVE temp AS (
//        SELECT * FROM sys_resource r WHERE r.resource_id =1200
//        UNION ALL
//        SELECT r.* FROM sys_resource r,temp t WHERE t.resource_id = r.parent_id
//)select * from temp
//
//
////-- 子 求 父
//WITH RECURSIVE temp AS (
//        SELECT * FROM sys_resource r WHERE r.resource_id =1210
//        UNION ALL
//        SELECT r.* FROM sys_resource r,temp t WHERE t.parent_id = r.resource_id
//)select * from temp





}
